using _RobotInspection.Models;
using _RobotInspection.DTO;
using Microsoft.AspNetCore.Mvc;

namespace _RobotInspection.Interfaces
{
    public interface IDailyInspectionManagementService
    {

        /// <summary>
        /// 根据任务ID获取设备详情及点检项次清单，可按状态筛选，并支持分页（与 GetInspectionPlansPaged 一致的分页字段）
        /// </summary>
        /// <param name="taskId">任务ID</param>
        /// <param name="pageIndex">页码（从1开始）</param>
        /// <param name="pageSize">页大小（默认20）</param>
        /// <param name="status">项次状态过滤（可选：1-正常，2-异常，3-待处理）</param>
        /// <returns>设备任务详情及项次分页结果</returns>
        Task<ApiResponse<EquipmentTaskDetailDto>> GetTaskDetailsAsync(long taskId, int pageIndex = 1, int pageSize = 20, byte? status = null);

        /// <summary>
        /// 更新或保存点检项次执行结果（支持巡检照片、修复图片、异常责任方、关注事项）
        /// </summary>
        /// <param name="taskId">任务ID</param>
        /// <param name="actualValue">实际值</param>
        /// <param name="resultStatus">结果状态：1-正常，2-异常，3-待处理</param>
        /// <param name="remark">备注</param>
        /// <param name="inspectionPhoto">巡检照片文件（可选）</param>
        /// <param name="repairPhoto">修复图片文件（可选，异常时可上传）</param>
        /// <param name="inspectionTime">检查时间（可选，不传默认当前时间）</param>
        /// <param name="issueDescription">问题描述（异常时建议填写）</param>
        /// <param name="nextAssignParty">下一步责任方（异常时必填，用于创建异常记录）</param>
        /// <param name="inspectorId">检查人ID（可选）</param>
        /// <param name="recordId">点检记录ID（必填；按主键更新并校验所属任务）</param>
        /// <param name="addAttentionItem">是否添加到关注事项（可选）</param>
        /// <param name="attentionAbnormalName">关注事项的异常名称（添加关注事项时建议填写）</param>
        /// <param name="attentionDescription">关注事项的异常描述（添加关注事项时可选）</param>
        /// <param name="reporterUserId">关注事项上报人ID（可选，默认使用 inspectorId）</param>
        Task<ApiResponse<object>> UpsertRecordAsync(long taskId, string actualValue, byte resultStatus, string? remark = null, Microsoft.AspNetCore.Http.IFormFile? inspectionPhoto = null, Microsoft.AspNetCore.Http.IFormFile? repairPhoto = null, DateTime? inspectionTime = null, string? issueDescription = null, string? nextAssignParty = null, long? inspectorId = null, bool? addAttentionItem = null, string? attentionAbnormalName = null, string? attentionDescription = null, long? reporterUserId = null, long recordId = 0);

        /// <summary>
        /// 获取当前用户在指定日期的设备列表（按任务的 plan_id 与 equipment_id 关联计划与设备，
        /// 并统计 inspection_plan_items 的总项次与 inspection_records 的已完成项次）。
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <param name="date">目标日期</param>
        /// <param name="planType">计划类型过滤：1-日，2-周，3-月，4-一次性</param>
        /// <param name="keyword">设备名称或编码模糊查询</param>
        /// <param name="statusFilter">完成状态过滤：1-已完成，0-未完成</param>
        /// <returns>设备列表</returns>
        Task<ApiResponse<List<DailyEquipmentSummaryDto>>> GetUserDailyEquipmentSummaryAsync(long userId, DateTime date, byte? planType = null, string? keyword = null, byte? statusFilter = null);
        /// <summary>
        /// 根据记录ID获取点检详情
        /// </summary>
        /// <param name="recordId">记录ID</param>
        /// <returns>点检记录详情</returns>
        Task<ApiResponse<InspectionRecordDetailDto>> GetRecordByIdAsync(long recordId);
        /// <summary>
        /// 根据用户与设备在指定日期获取对应任务ID
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <param name="equipmentId">设备ID</param>
        /// <param name="date">目标日期</param>
        /// <returns>任务ID</returns>
        Task<ApiResponse<object>> GetTaskIdForUserAndEquipmentAsync(long userId, long equipmentId, DateTime date);
    }
}
